﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Threading;   
using System.Windows.Controls.Primitives;   
using System.ComponentModel;
using Microsoft.Phone.Shell;


namespace QRCodeForWP
{
    public partial class MainPage : PhoneApplicationPage
    {
       private BackgroundWorker backroungWorker;   
       private Popup myPopup;  

        // Constructor
        public MainPage()
        {
            InitializeComponent();
        
            myPopup = new Popup() { IsOpen = true, Child = new SplashScreen() };

            backroungWorker = new BackgroundWorker();
            RunBackgroundWorker();
            this.SetValue(SystemTray.IsVisibleProperty, false);
        }

        private void RunBackgroundWorker()
        {
            backroungWorker.DoWork += ((s, args) =>
            {
                Thread.Sleep(3000);
            });

            backroungWorker.RunWorkerCompleted += ((s, args) =>
            {
                this.Dispatcher.BeginInvoke(() =>
                {
                    this.myPopup.IsOpen = false;
                });
            });

            backroungWorker.RunWorkerAsync();
        }

        private void btnMake_Click(object sender, RoutedEventArgs e)
        {
            //var img = WP7BarcodeManager.CreateBarcode();
            //WP7BarcodeManager.SaveJPEGToIsolatedStorage(img,"test.jpg");
            //this.imgQRCode.Source = img;

        }

        
    }
}